package com.tecode;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

public class TestMain {

    public static void main(String[] args) {


        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("NewPersistenceUnit");

        EntityManager entityManager = entityManagerFactory.createEntityManager();


        EntityTransaction transaction = entityManager.getTransaction();

        transaction.begin();

        JpaUser jpaUser = new JpaUser();
        jpaUser.setAge(10);
        jpaUser.setEmail("123@163.com");
        jpaUser.setName("abc");
        //entityManager.persist(jpaUser);
        JpaUser jpaUser1 = entityManager.find(JpaUser.class, 1);
        System.out.println(jpaUser1);
        transaction.commit();
        entityManager.close();

        entityManagerFactory.close();
    }
}
